/*
 * @Descripttion:
 * @Author: voanit
 * @Date: 2022-03-28 08:23:16
 * @LastEditors: voanit
 * @LastEditTime: 2022-04-04 15:37:34
 */
import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import locale from "element-ui/lib/locale/lang/en"; // lang i18n

// import '@/styles/index.scss' // global css
import "@/styles/index.scss";

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/permission"; // permission control

/**
 * If you don't want to use mock-server
 * you want to use MockJs for mock api
 * you can execute: mockXHR()
 *
 * Currently MockJs will be used in the production environment,
 * please remove it before going online ! ! !
 */
// if (process.env.NODE_ENV === 'production') {
//   const { mockXHR } = require('../mock')
//   mockXHR()
// }

// set ElementUI lang to EN
Vue.use(ElementUI);
// 如果想要中文版 element-ui，按如下方式声明
// Vue.use(ElementUI)

/* 自定义指令 */
// Vue.directive('自定义指令的名字',{})
Vue.directive("errorImg", {
  inserted(el, binding) {
    // console.log(el, 88777);
    el.onerror = function () {
      //元素加载执行的时候出现错误就会触发这个事件，事件触发：表示资源加载失败
      // console.log("error===1111");
      /* 
      解决方法：如果图片加载失败：就显示默认图片，加载成功就不用管
      */
      el.src = binding.value;
    };
  },
});



// import PageTools from "@/components/PageTools"; 
// Vue.component("PageTools", PageTools);

// import pluginCom from "@/components/index";
// Vue.use(pluginCom)
import pluginCom from "@/components";
Vue.use(pluginCom);


import dayjs from "dayjs";
Vue.filter("forMat", (data,p1) => {
  return dayjs(data).format(p1);
});








Vue.config.productionTip = false;

new Vue({
  el: "#app",
  router,
  store,
  render: (h) => h(App),
});

/* Vue.filter("forMat", (data) => {
  var t = new Date(data)
  console.log(t, 123);
  var yy = t.getFullYear()
  var mm = (t.getMonth() + 1).toString().padStart(2.0)
  var dd = t.getDate.toString().padStart(2.0)
  return `${yy}-${mm}-${dd}`
}) */